User:Lar/monobook.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//<pre><nowiki>
//---------------------------------------------------------------

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Script loading function by Quarl (http://en.wikipedia.org/wiki/User:Quarl)
/////////////////////////////////////////////////////////////////////////////////////////////////////////
function winc(s) {
    s = s.replace(/^\[\[/, '').replace(/\]\]$/, '');
    document.write('<script type="text/javascript" src="'
             + 'http://en.wikipedia.org/w/index.php?title=' + s
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
}

/////////////////////////////////////////////////////
// Spellchecker (cribbed from [[user:pschemp]]'s cribbing from somewhere else
// you can get this code by doing a {{subst:spellcheck}} in a sandbox somewhere
/////////////////////////////////////////////////////

 document.write('<script ' 
            + 'type="text/javascript" src="http://en.wiktionary.org'
            + '/w/index.php?title=User:Connel_' 
            + 'MacKenzie/spellcheck.js&action=raw&ctype=text/javascript"><\/' 
            + 'script>');

// ---------- tab manipulation functions --------------

// **** Add tab to tab structure  with name 'tabname' with function 'url' and label 'name'****

function addlilinkExisting(tabname, url, name, id) { 
   tabs = document.getElementById(tabname).getElementsByTagName('ul')[0];
   addlilink(tabs, url, name, id);
}
// **** Add tab to tab structure 'tabs' with function 'url' and label 'name'****

function addlilink(tabs, url, name, id){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}

function insertlilinkBefore() {

//>	parent.insertBefore(node, referenceNode.nextSibling);
}

function findORaddlimenu(tabset, name, id)
{
}

// there is a version of the above in User:Voice_of_All/Addtabs/monobook.js

function addlimenu(tabset, name, id)
{
    var na = document.createElement('a');
    na.href = '#';
    var mn = document.createElement('ul');
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.className = 'tabmenu';
    li.appendChild(na);
    li.appendChild(mn);
    tabset.appendChild(li);
    return li;
}
//First loads
//Helper tools for tabs

// Helper tools (addtabs mandatory for other functions)
winc('[[User:Voice_of_All/Addtabs/monobook.js]]');  

// UTC clock
winc('[[User:Voice_of_All/UTCclock.js]]'); 

// Deletion
winc('[[User:Voice_of_All/Deletion/monobook.js]]'); 

// Replace txt
winc('[[User:Voice_of_All/replacetxt.js]]'); 

// Admin protection tools
winc('[[User:Voice_of_All/Protection/monobook.js]]'); 

// Checkuser enhancements
winc ('[[User:Voice_of_All/CheckUser/monobook.js]]');

//DYK functions
winc('[[User:Lar/DYK/monobook.js]]');


//Help delete things on NowCommons tagging function
winc('[[User:Lar/dellinkNowCommons.js]]');


// History analysis: 
// Analyzes a page history when "statistics" tab is clicked. Shows a whole range of useful data. 
// Also gives quick edit summary %  usage and namespace % based on all edits appearing on the 
// contributions page. taken from [[User:Voice_of_All/History/monobook.js]]

// History tools
winc('[[User:Voice_of_All/History/monobook.js]]'); 

// AfD helper (vote automation tool)

/**** afd helper ****/

winc('[[User:Jnothman/afd_helper/script.js]]'); 

/* This is to keep track of who is using this extension: [[User:Jnothman/afd_helper/script.js]] */

afdh_signature='~~'+'~~';

// misc tabs cribbed from [[/User:Pschemp/monobook.js]] who cribbed it from somewhere else

winc('[[User:Lar/moretabs/monobook.js]]')


//live-preview stuff
wpUserName = 'Lar';
wpShowImages = true;

winc('[[User:Pilaf/livepreview.js]]'); 

//document.write('<script type="text/javascript" //src="http://en.wikipedia.org/w/index.php?title=User:Pilaf/livepreview.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//---------------------------------------------------------------
function URLEncoding(input)
      {
        var encodedInputString=escape(input);
        encodedInputString=encodedInputString.replace("+", "%2B").replace("+", "%2B").replace("+", "%2B");
        encodedInputString=encodedInputString.replace("/", "%2F").replace("/", "%2F").replace("/", "%2F");   
        encodedInputString=encodedInputString.replace("&","%26").replace("&","%26").replace("&","%26");     
        var outputurl=encodedInputString;
        return outputurl;
      }
//END


//---------------------------------------------------------------
/* like submitting the URL http://en.wikipedia.org/w/index.php?title={{{PAGENAME}}}&action=purge */

function addpurge() {
    ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
    if(!document.getElementById) return;
    var x = document.getElementById('ca-history');
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if(!x) return;
    if(x.children) x = x.children[0];
    else x = x.childNodes[0];
    addlilink(tabs, x.href.replace(/=history/, "=purge"), 'purge', 'ca-purge');
}


//---------------------------------------------------------------
//Toolbox links
function changelinks() {
    if(!document.getElementById) return;
    document.getElementById('pt-mytalk').firstChild.innerHTML = 'my Talk';
    document.getElementById('pt-preferences').firstChild.innerHTML = 'Change Prefs';
    document.getElementById('pt-watchlist').firstChild.innerHTML = 'My Watchlist';
    document.getElementById('pt-mycontris').firstChild.innerHTML = 'My Contribs';
    document.getElementById('pt-logout').firstChild.innerHTML = 'Log out';
}
function addtoolboxlinks() {
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, '/wiki/Special:Newpages', 'New pages', '');
    addlilink(tb, '/wiki/Special:Log/newusers', 'New users', '');
    addlilink(tb, '/wiki/Category:Candidates_for_speedy_deletion', 'Speedy deletions', '');
    addlilink(tb, '/wiki/Wikipedia:Administrator_intervention_against_vandalism', 'Vandalism', '');
    addlilink(tb, '/wiki/WP:RfPP', 'Protection requests', '');
    addlilink(tb, '/wiki/WP:PP', 'Protected pages', '');
    addlilink(tb, '/wiki/Wikipedia:Administrators%27_noticeboard', 'Noticeboard', '');
    addlilink(tb, '/wiki/Wikipedia:Administrators%27_noticeboard/3RR', '3RR violations', '');
    addlilink(tb, '/wiki/Wikipedia:Template messages/User_talk_namespace', 'Talk templates', '');
    addlilink(tb, '/wiki/Wikipedia:Template_messages', 'Templates', '');
    addlilink(tb, '/wiki/WP:CSD', 'SD criteria', '');
    addlilink(tb, '/wiki/Special:Log', 'Log', '');
    addlilink(tb, '/wiki/Special:Log/delete', 'Delete log', '');
    addlilink(tb, '/wiki/Special:Log/block', 'Block log', '');
    addlilink(tb, '/wiki/Special:Ipblocklist', 'IPBlocklist', '');
    addlilink(tb, '/wiki/Category:Request for Unblock', 'Unblock requests', '');
    addlilink(tb, '/wiki/Category:Wikipedia spam cleanup', 'Spam cleanup', '');
}
//END

// ======== USER TABS =======
 addOnloadHook(function() {
   if (document.title.search("/") != -1 || document.title.search("- History -") != -1) { //no subpages or history
      return;
   }
   if (document.title.indexOf("User:") == 0 || document.title.indexOf("User talk:") == 0) {
      username_a = document.URL.match(/:.*:(.*)/);
      username=username_a[1];
      addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=&page=User:" + username, "log", "ca-blog", "block log", "");
      addTab("http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=enwiki_p&user=" + username, "info", "ca-kate", "user info", "");
   }
 });

//************

//************
//LAST DIFF TAB
function lastdiff() 
    {
    if (document.title.indexOf("Editing ") != -1)
    {return;}
    z=document.getElementById("content").childNodes;
    for (var n=0;n<z.length;n++) { 
      if (z[n].className=="firstHeading") 
      {
  var pname=document.title.split(' - ')[0].replace(/&/g,'%26').replace(/\\+/g, '%2B');
      }
    }
addTab("http://en.wikipedia.org/w/index.php?title=" + pname + "&diff=cur&oldid=prev", "Last", "ca-diff", "Show most recent diff", "");
}

// This will add an [edit top] link at the top of all pages except preview pages
function addtoplink()
{
var edittop = '<span style="color:black;">[</span>edit top<span style="color:black;">]</span>';
  // if this is preview page or generated page, stop
  if(document.getElementById("wikiPreview") || window.location.href.indexOf("w/index.php?title=Special:") != -1) return;
  if(document.title.indexOf("Main Page") != -1) return;

  // get the page title
  var pageTitle = document.title.split(" - ")[0].replace(" ", "_"); 

  // create div and set innerHTML to link
  var divContainer = document.createElement("div");
  divContainer.innerHTML = '<div class="editsection" style="float:right;margin-left:5px;margin-right:35px;margin-top:3px;"><a href="/w/index.php?title='+pageTitle+'&action=edit&section=0" title="'+document.title.split(" - ")[0]+'">' + edittop + '</a></div>';

  // insert divContainer into the DOM before the h1
if (document.getElementById("content") !=undefined) {
  document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);}
}
//END

//************
//MAIN
//************

$(Mainfast)
function Mainfast() 
{
    changemovetab();
    changelinks();
    addpurge();
    addtoolboxlinks();
    add_more_tabs();

}

window.onload = Main;
function Main() 
{
    addtoplink();
    LivePreviewInstall();
//    if(addSinceTab)
//    {addSinceTab();}
}
//END
//************

//
Mvaluejsadmin = 'DMalak1';
Rvaluejsadmin = 'ERollenH1';
//
//************
//Slow load tools
//Admin rollback tools
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Specialadmin/monobook.js' 
             + '&action=raw&ctype=text/javascript');
//END
// Script from [[User:MarkS/extraeditbuttons.js]]
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:MarkS/extraeditbuttons.js' 
             + '&action=raw&ctype=text/javascript');
//END
//New user log tools
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Sleeper/monobook.js' 
             + '&action=raw&ctype=text/javascript');
//END
//Admin warning tools
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Adminwarnings/monobook.js' 
             + '&action=raw&ctype=text/javascript');
//END
//Delete tabs
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Deletion/monobook.js' 
             + '&action=raw&ctype=text/javascript');
//END
//************
//Google tools
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Google/monobook.js' 
             + '&action=raw&ctype=text/javascript');
//END

//Zocky's search box
winc('[[User:Zocky/SearchBox.js]]');

//document.write('<script type="text/javascript" src="' 
//             + 'http://en.wikipedia.org/w/index.php?title=User:Zocky/SearchBox.js' 
//             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//Interiot's javascript edit counter

if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) {
winc('[[User:Interiot/Tool2/code.js]]');

//  document.write('<script type="text/javascript" src="' 
//    + 'http://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js' 
//    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); 
}

//************
//Lupin's tools
//************
//Filter changes live [[Category:Wikipedia administrators who use VoA script]]
//[[User:Lupin/recent2.js]] - please include this line
winc('[[User:Lupin/recent2.js]]');

//document.write('<script type="text/javascript" src="' 
//             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js' 
//             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//[[User:Lupin/popupsdev.js]] - please include this line 
winc('[[User:Lupin/popupsdev.js]]');

//document.write('<script type="text/javascript" src="' 
//             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popupsdev.js' 
//             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

popupShortcutKeys=true; // optional: enable keyboard shortcuts

// I am an admin so do use this
popupAdminLinks=true;   // optional: enable admin links [[Category:Wikipedia administrators who use VoA script]]
popupSubpopups=false;
popupStructure='shortmenus';
popupDelay=1.0;          // optional: time in s before popup happens (slowed down from default of .5s
popupEditCounterTool='interiot';  // other value is 'kate' but I prefer interiot's as it has more features
popupOnEditSelection=false; // I do not want popups for links that I select while editing.
popupFixDabs=true;          // I do want to be able to fix disambigs

popupExtendedRevertSummary='Revert to version $1 by $2 using [[:en:Wikipedia:Tools/Navigation_popups|popups]]';


//

//Change move tab name
function changemovetab()
{
if (document.title.indexOf("Talk:") == -1 && document.title.indexOf("talk:") == -1 && document.title.indexOf("User:") == -1 && document.title.indexOf("MediaWiki:") == -1 && document.title.indexOf("Image:") == -1 && document.title.indexOf("Wikipedia:") == -1 && document.title.indexOf("Template:") == -1 && document.title.indexOf("Portal:") == -1 && document.title.indexOf("Help:") == -1 && document.title.indexOf("Main Page") == -1 && document.title.indexOf("Category:") == -1)
  {
  if(document.getElementById('ca-edit'))
  {document.getElementById('ca-edit').firstChild.innerHTML = 'Modify';}
  if(document.getElementById('ca-move'))
  {document.getElementById('ca-move').firstChild.innerHTML = 'Rename';}
  if(document.getElementById('ca-history'))
  {document.getElementById('ca-history').firstChild.innerHTML = 'Revisions';}
  }
if (document.title.split(' - ')[0].split(".js")[1] != undefined)
  {
  if (document.title.split(' - ')[0].split(".js")[1] != undefined)
     {
      if(document.getElementById('ca-nstab-main'))
      {
      document.getElementById('ca-nstab-main').firstChild.innerHTML = 'Javascript';
      }  
      else if(document.getElementById('ca-nstab-user'))
      {
      document.getElementById('ca-nstab-user').firstChild.innerHTML = 'User JS';
      } 
      else if(document.getElementById('ca-nstab-mediawiki'))
      {
      document.getElementById('ca-nstab-mediawiki').firstChild.innerHTML = 'MediaWiki JS';
      }  
    }
  }
}
//END

//***************
// Krimpet's commons helper helper

// [[User:Krimpet/CH2.js]]
importScript('User:Krimpet/CH2.js');


//*********************
// Henrik's DYK notifier helper

importScript('User:Henrik/js/dyk-notifier.js');

//*********************
// Dr pda's prose size checker

importScript('User:Dr pda/prosesizebytes.js');


//*********************
// Google custom search

document.write('<script type="text/javascript" src="http://en.wikipedia.org/w/index.php?title=User:Csewiki/monobook.js&action=raw&ctype=text/javascript&dontcountme=s"><\/script>');
document.write('<link rel="stylesheet" type="text/css" href="http://en.wikipedia.org/w/index.php?title=User:Csewiki/monobook.css&action=raw&ctype=text/css&dontcountme=s"><\/link>');


//************
//</nowiki></pre>[[Category:Wikipedia administrators who use VoA script|Lar]]